#include<bits/stdc++.h>
using namespace std;
long long n,m,l,vc,p[100010],ps,t,pk[100010]={0},cnt;
struct car0{
    long long d,vs,a;
    double x;
}car[100010];
int bugg1(){
    int cnt=0;
    for(int k=1;k<=n;k++){
        if(car[k].a!=0) cnt++;
    }
    if(cnt==0) return 1;
    else return 0;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int i=1;i<=t;i++){
    ps=0; memset(pk,0,sizeof(pk)); cnt=0;
    cin>>n>>m>>l>>vc;
    for(int j=1;j<=n;j++){
        cin>>car[j].d>>car[j].vs>>car[j].a;
        if(car[j].a==0) car[j].x=car[j].d;
        else car[j].x=car[j].d+(double(vc*vc-car[j].vs*car[j].vs))/(2*((double)car[j].a));
    }
    for(int j=1;j<=m;j++)
        cin>>p[j];
    if(bugg1()==1){
        for(int j=1;j<=n;j++){
            if(car[j].vs>vc) ps++;
        }
        if(ps==0)
            cout<<ps<<" "<<m<<endl;
        else
            cout<<ps<<" "<<m-1<<endl;

    }
    else{
        for(int j=1;j<=n;j++){
            if(car[j].a<=0){
                if(car[j].vs>vc){
                    int plesl=(long long)((lower_bound(p,p+m+1,car[j].x))-&p[0]);
                    int plesr=(long long)((lower_bound(p,p+m+1,car[j].x))-&p[0]);
                    //if(plesl!=plesr){
                    ps++; pk[plesl]++;
                //}
            }
            }
            else{
                int plesl=(long long)((lower_bound(p,p+m+1,car[j].x))-&p[0]);
                int plesr=(long long)((lower_bound(p,p+m+1,car[j].x))-&p[0]);
                if(plesl!=plesr){
                    ps++; pk[plesl]++;
                }
            }
        }
        for(int j=1;j<=m;j++){
            if(pk[j]!=0) cnt++;
        }
        cout<<ps<<" "<<m-cnt;
    }
    }
    return 0;
}
